package d_用户信息.c_获取手机号.a_获取手机号;

import a_接口调用凭证.a_获取接口调用凭据.GetAccessToken;
import com.fasterxml.jackson.annotation.JsonProperty;
import my.wechat.rc.common.HttpClientUtil;
import my.wechat.rc.common.MapUtil;

/**
 * @author 86153
 * @date 2022/8/5
 **/
public class GetPhoneNumber {

    public static GetPhoneNumberResponse getPhoneNumber() {
        try {
            String accessToken = GetAccessToken.getAccessToken().getAccessToken();
            String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
            return HttpClientUtil.post(url, MapUtil.of("code", ""),
                    GetPhoneNumberResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new GetPhoneNumberResponse();
    }

    public static void main(String[] args) {
        getPhoneNumber();
    }

    public static class GetPhoneNumberResponse {
        private Integer errcode;
        private String errmsg;
        @JsonProperty("phone_info")
        private PhoneInfo phoneInfo;

        public Integer getErrcode() {
            return errcode;
        }

        public void setErrcode(Integer errcode) {
            this.errcode = errcode;
        }

        public String getErrmsg() {
            return errmsg;
        }

        public void setErrmsg(String errmsg) {
            this.errmsg = errmsg;
        }

        public PhoneInfo getPhoneInfo() {
            return phoneInfo;
        }

        public void setPhoneInfo(PhoneInfo phoneInfo) {
            this.phoneInfo = phoneInfo;
        }

        public static class PhoneInfo {
            private String phoneNumber;
            private String purePhoneNumber;
            private String countryCode;
            private Watermark watermark;

            public String getPhoneNumber() {
                return phoneNumber;
            }

            public void setPhoneNumber(String phoneNumber) {
                this.phoneNumber = phoneNumber;
            }

            public String getPurePhoneNumber() {
                return purePhoneNumber;
            }

            public void setPurePhoneNumber(String purePhoneNumber) {
                this.purePhoneNumber = purePhoneNumber;
            }

            public String getCountryCode() {
                return countryCode;
            }

            public void setCountryCode(String countryCode) {
                this.countryCode = countryCode;
            }

            public Watermark getWatermark() {
                return watermark;
            }

            public void setWatermark(Watermark watermark) {
                this.watermark = watermark;
            }

            public static class Watermark {
                private Integer timestamp;
                private String appid;

                public Integer getTimestamp() {
                    return timestamp;
                }

                public void setTimestamp(Integer timestamp) {
                    this.timestamp = timestamp;
                }

                public String getAppid() {
                    return appid;
                }

                public void setAppid(String appid) {
                    this.appid = appid;
                }
            }
        }
    }

}
